USE Travian;

IF EXISTS (
           SELECT *
             FROM Travian.dbo.sysobjects
            WHERE Name = 'x_world'
              AND TYPE = 'u')
DROP TABLE x_world
CREATE TABLE x_world(
Vid integer NOT NULL ,
x integer NOT NULL,
y integer NOT NULL,
tid integer NOT NULL,
distance_id integer NOT NULL,
village VARCHAR(50) NOT NULL,
uid integer NOT NULL,
player VARCHAR(50) NOT NULL,
aid integer NOT NULL,
alliance VARCHAR(20) NOT NULL,
Population integer NOT NULL
)
IF EXISTS (
           SELECT *
             FROM Travian.dbo.sysobjects
            WHERE Name = 'races'
              AND TYPE = 'u')
DROP TABLE races
CREATE TABLE races(
Race_id integer IDENTITY(1,1) PRIMARY KEY ,
Race_name VARCHAR(11) NOT NULL
)
IF EXISTS (
           SELECT *
             FROM Travian.dbo.sysobjects
            WHERE Name = 'commands'
              AND TYPE = 'u')
DROP TABLE commands
CREATE TABLE commands(
Command_id integer IDENTITY(1,1) PRIMARY KEY,
Command_Name VARCHAR(12) NOT NULL,
Access_lvl integer NOT NULL)

IF EXISTS (
           SELECT *
             FROM Travian.dbo.sysobjects
            WHERE Name = 'units'
              AND TYPE = 'u')
DROP TABLE units
CREATE TABLE units(
Unit_id integer IDENTITY(1,1) PRIMARY KEY,
Unit_Name VARCHAR(20) NOT NULL,
Unit_Race VARCHAR(11) NOT NULL,
Unit_Speed integer NOT NULL,
Loot integer NOT NULL,
Funct CHAR(1) NOT NULL,
Type CHAR(1) NOT NULL)

IF EXISTS(
			SELECT *
			FROM Travian.dbo.sysobjects
			WHERE Name = 'members'
			AND TYPE = 'u')
DROP TABLE members
CREATE TABLE members(
Member_ID integer IDENTITY(1,1) PRIMARY KEY,
Member_Name VARCHAR(20) NOT NULL,
JoinDate TIMESTAMP,
Access_lvl integer DEFAULT 3,
Race_ID integer NOT NULL)

IF EXISTS(
			SELECT *
			FROM Travian.dbo.sysobjects
			WHERE Name ='priveleged_members'
			AND TYPE = 'u')
DROP TABLE priveleged_members
CREATE TABLE priveleged_members(
PID integer IDENTITY(1,1) PRIMARY KEY,
Access_lvl integer)

IF EXISTS(
			SELECT *
			FROM Travian.dbo.sysobjects
			WHERE Name = 'website_users'
			AND TYPE = 'u')
DROP TABLE website_users
CREATE TABLE website_users (
WebUser_ID integer IDENTITY(1,1) PRIMARY KEY,
WebUserName varchar(20),
Web_Password varchar(20),
Web_Email varchar(50),
Web_FullName varchar(50),
Web_Country varchar(15),
Player_ID integer)



